#ifndef FileTransferEntry_H
#define FileTransferEntry_H

#include <wx/file.h>
#include <wx/filename.h>

#include "MsnDef.h"

class MsnSession;

class P2PMessage;

class P2PConnection;

/*
struct FileTransferItem
{
	MsnSession* session;

	wxString protocal;

	wxString cookie;
    wxString fileName;
    wxString filePath;
	unsigned long fileSize;

	wxFile* file;


	bool isSender;
	bool senderConnect;
   
};
*/

class FileTransferEntry
{
friend class FileTransferManager;

public:	
	wxString protocal;
	
	bool isSender;
	bool senderConnect;

private:
	
	MsnSession* session;

	bool cancelled;

	wxString ID;

	wxString callID;

	int appID;

	int messageID;

	wxFile* file;

	wxString fileName;
    wxString filePath;

	unsigned long fileSize;
	unsigned long fileOffset;

	time_t notifyTime;
	int notifySize;

	P2PConnection* connection;

	P2PMessage* message;

public:
	FileTransferEntry();
	~FileTransferEntry();

	MsnSession* GetSession(){return session;}
	void SetSession(MsnSession* ms){session = ms;}

	wxString GetID(){return ID;}
	void SetID(const wxString& id){ID = id;}

	int GetAppID(){return appID;}
	void SetAppID(int aid){appID = aid;}

	void SetCallID(const wxString& cid){callID = cid;}
	wxString GetCallID(){return callID;}

	int GetMessageID(){return messageID;}
	void SetMessageID(int id){messageID = id;}

	wxString GetFileName(){return fileName;}
	void SetFileName(const wxString& name){fileName = name;}

	wxString GetFilePath(){return filePath;}
	void SetFilePath(const wxString& path){filePath = path;}

	unsigned long GetFileSize(){return fileSize;}
	void SetFileSize(unsigned long size){fileSize = size;}

	unsigned long GetFileOffset(){return fileOffset;}
	void SetFileOffset(unsigned long offset){fileOffset = offset;}

	void SetMessage(P2PMessage* msg);
	P2PMessage* GetMessage(){return message;};

	void SetConnection(P2PConnection* conn){connection = conn;}
	P2PConnection* GetConnection(){return connection;}

	bool IsCancelled(){return cancelled;}

public:

	bool IsDisplayPicture(){return appID == MSN_P2P_APP_ID_DISPLAY_PICTURE;}

	bool IsFileTransfer(){return appID == MSN_P2P_APP_ID_DISPLAY_PICTURE;}

	int GetTransferType(){return appID;}

	bool OpenFile(bool readOnly);
	void CloseFile();

	void WriteFileData(char* buf, int size);
	int ReadFileData(char* buf, int size);

	bool IsDone(){return fileOffset == fileSize;};

	void CancelTransfer();

	

};


#endif

